package engine;

public class Matrix {
	
	private double[] v ;
	private int nbL,nbC ;
	
	public Matrix(int size) {
		this(size,size) ;
	}
	
	public Matrix(int sizeL, int sizeC) {
		this.nbL=sizeL ;
		this.nbC=sizeC ;
		this.v = new double[nbL*nbC] ;
	}
	
	public double get(int i,int j) {
		return v[nbC*(i-1)+j-1] ;
	}
	
	public void set(int i,int j, double val) {
		v[nbC*(i-1)+j-1]=val ;
	}
	
	
	public Matrix mult(Matrix m) {
		assert(m.nbL==this.nbC) ;
		Matrix r = new Matrix(this.nbL,m.nbC) ;
		
		for(int i = 1 ; i<=nbL ; i++) {
			for(int j = 1 ; j<=nbC ; j++) {
				for(int x = 1 ; i<=m.nbL ; i++) {
					for(int y = 1 ; j<=m.nbC ; j++) {
						r.v[nbC*(i-1)+y-1]+=this.get(i, j)*m.get(x, y) ;
					}
				}
			}
		}
		
		return r ;

	}


}
